import 'package:json_annotation/json_annotation.dart';

part 'product.g.dart';

@JsonSerializable()
class NewProductModel {
  String imgUrl;

  String name;

  int price;

  NewProductModel({required this.imgUrl, required this.name, required this.price});

  factory NewProductModel.fromJson(Map<String, dynamic> json) => _$NewProductModelFromJson(json);

  Map<String, dynamic> toJson() => _$NewProductModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class BargainProductModel {
  String imgUrl;

  int sendCount;

  String name;

  BargainProductModel({required this.imgUrl, required this.name, required this.sendCount});

  factory BargainProductModel.fromJson(Map<String, dynamic> json) =>
      _$BargainProductModelFromJson(json);

  Map<String, dynamic> toJson() => _$BargainProductModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class GroupBuyProductModel {
  /// 商品图片
  String imgUrl;

  /// 商品名称
  String name;

  /// 数量
  int count;

  /// 单位
  String unit;

  /// 原价
  double originalPrice;

  /// 售价
  double sellPrice;

  /// 最低成团人数
  int groupCount;

  GroupBuyProductModel(
      {required this.imgUrl,
      required this.name,
      required this.count,
      required this.unit,
      required this.originalPrice,
      required this.sellPrice,
      required this.groupCount});

  factory GroupBuyProductModel.fromJson(Map<String, dynamic> json) =>
      _$GroupBuyProductModelFromJson(json);

  Map<String, dynamic> toJson() => _$GroupBuyProductModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class SpellOrderProductModel {
  /// 用户头像
  String avatar;

  /// 用户昵称
  String nickname;

  /// 拼单价格
  double price;

  /// 拼单人数
  int spellCount;

  /// 还差人数
  int differCount;

  /// 剩余时间
  String residueTime;

  SpellOrderProductModel(
      {required this.avatar,
      required this.nickname,
      required this.price,
      required this.spellCount,
      required this.differCount,
      required this.residueTime});

  factory SpellOrderProductModel.fromJson(Map<String, dynamic> json) =>
      _$SpellOrderProductModelFromJson(json);

  Map<String, dynamic> toJson() => _$SpellOrderProductModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}
